<!DOCTYPE html>
<html lang="en">
<head>
<title>山东大学(威海)贴吧官方登陆</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!--图标样式-->
<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">

<!--布局框架-->
<link rel="stylesheet" type="text/css" href="css/util.css">

<!--主要样式-->
<link rel="stylesheet" type="text/css" href="css/main.css">

</head>

<body>
    <div class="alert"></div>
    <div class="limiter">
        <div class="container-login100" style="background-image: url('images/logo.jpg');">
            <div class="wrap-login100 p-t-190 p-b-30">
                <div class="login100-form validate-form">
                    <div class="login100-form-avatar">
                        <img src="images/avatar-01.jpg" alt="AVATAR">
                    </div>

                    <span class="login100-form-title p-t-20 p-b-45">欢迎注册</span>

                    <div class="wrap-input100 validate-input m-b-10" data-validate="请输入用户名">
                        <input class="input100" type="email" name="username" placeholder="用户名" autocomplete="off">
                        <span class="focus-input100"></span>
                        <span class="symbol-input100">
                            <i class="fa fa-user"></i>
                        </span>
                    </div>

                    <div class="wrap-input100 validate-input m-b-10" data-validate="请输入密码">
                        <input class="input100" type="password" name="pass" placeholder="密码">
                        <span class="focus-input100"></span>
                        <span class="symbol-input100">
                            <i class="fa fa-lock"></i>
                        </span>
                    </div>

                    <div class="wrap-input100 validate-input m-b-10" data-validate="请确认密码">
                        <input class="input100" type="password" name="passre" check="true" placeholder="确认密码">
                        <span class="focus-input100"></span>
                        <span class="symbol-input100">
                            <i class="fa fa-lock"></i>
                        </span>
                    </div>

                    <div class="container-login100-form-btn p-t-10">
                        <button class="login100-form-btn" onclick="submitRegistry()">注册</button>
                    </div>

                    <!-- <div class="text-center w-full p-t-25 p-b-230">
                        <a href="#" class="txt1">忘记密码？</a>
                    </div> -->

                    <div class="text-center w-full p-t-25 p-b-230">
                        <a class="txt1" href="https://www.maksdu.com/login/">
                            立即登录
                            <i class="fa fa-long-arrow-right"></i>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="js/jquery-1.12.4.min.js"></script>
    <script src="js/jquery.cookie.js"></script>
    <script src="js/main.js"></script>
    <script type="text/javascript">

        function submitRegistry() {
            var unm = $("input[name='username']").val();
            var pwd = $("input[name='pass']").val();
            var repwd = $("input[name='passre']").val();
            if(unm.length<6) {
                $('.alert').html('用户名长度不能少于6位').addClass('alert-danger').show().delay(1500).fadeOut();
                return;
            }

            if(pwd.length < 6 || repwd.length < 6) {
                $('.alert').html('密码长度不能少于6位').addClass('alert-danger').show().delay(1500).fadeOut();
                return;
            }


            if(pwd==repwd) {
                $.ajax({
                    url:'https://www.maksdu.com/app/registry',
                    method: 'post',
                    data: {
                        name:unm,
                        password:pwd
                    },
                    success: function(result) {
			            console.info(result);
                        if(result.code == 200) {
                            var success = result.result;
                            if(success.auth_is_ok && success.value.code == 200) {
				                $('.alert').html('注册成功').addClass('alert-success').show().delay(1500).fadeOut();
                                $.cookie("username", unm, { expires: 1 });
                                setTimeout(function(){
                                    window.location.replace("https://www.maksdu.com/login/");
                                },1000);                                
                            } else {
                                if(success.value["code-type"] == "error")
                                    $('.alert').html('该用户已被注册').addClass('alert-danger').show().delay(1500).fadeOut();
                            }
                        }
                    }
                });
            } else {
               $('.alert').html('两次密码输入不一致').addClass('alert-danger').show().delay(1500).fadeOut();
            }
        }

        function checkPwdRe(input) {
            console.info(input);
        }

    </script>

</body>
</html>
